package com.tuo51.manager.vo;

import com.tuo51.evaluate.domain.tags.RelObjectTag;
import com.tuo51.evaluate.domain.tags.Tag;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 标签关系
 */
@Data
public class TagObjectRelationVO {

    private String tagId;

    private String objId;

    private List<TagVO> tags;

    private Object obj;

    // 对象类型， 1.question  2. storeItem   3.dimension   4.newsItem
    private Integer objType;

    public static TagObjectRelationVO of(RelObjectTag relation, Object obj, List<Tag> tags ){
        TagObjectRelationVO ret = new TagObjectRelationVO();

        ret.setObjId(relation.getObjId());
        ret.setObjType(relation.getObjType());
        ret.setTagId(relation.getTagId());

        ret.setTags(tags.stream().map(k->TagVO.of(k)).collect(Collectors.toList()));
        ret.setObj(obj);

        return ret;
    }

}
